#include "led.h"

void led_set(uint8_t *uled)
{
	uint8_t temp = 0x00;
	static uint8_t old_temp = 0xff;
	
	for(int i = 0;i<8;i++)
	{
		temp |= (uled[i]<<i); 
	}
	
	if(temp != old_temp)
	{
		GPIOC->ODR &=0xff;
		GPIOC->ODR |= ~(temp<<8);
		
		GPIOD->BSRR = (0x01) << 2;
		GPIOD->BRR = (0x01) << 2;
		
		old_temp = temp;
	}
	
}

uint8_t uled[8] = {0,0,0,0,0,0,0,0};

void led_proc(void)
{
	if(show_mode == 0)
	{
	uled[show_mode] = 1;
	}
	else
	{
	uled[show_mode] = 0;		
	}
	
	uled[2] = duty_clock;
	led_set(uled);

}

void led_shan_proc(void)
{
	if(mode_clock)
	{
		uled[1] ^= 1; 
	}
	else
	{
		uled[1] = 0; 
	}
}